home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Code Resources / Jims CDEFs 1.50 / demo Source ƒ / utilities / panelAssist.c < prev    next >
Encoding:
Text File  |  1995-10-27  |  2.5 KB  |  90 lines  |  [TEXT/KAHL]

  1. //----------------------------------------------------------------------------------
  2. //    File        : panelAssist.c
  3. //    Date        : August 24, 1994
  4. //    Author        : Jim Stout
  5. //    Purpose        : Some utility routines for use with the tabPanel CDEF.
  6. //
  7. //----------------------------------------------------------------------------------
  8. #include "dialogAssist.h"
  9. #include "panelAssist.h"
  10.  
  11. //----------------------------------------------------------------------------------
  12. //    Function: panelSwap
  13. //     Purpose: change a dialog panel in a dialog that uses the tabPanel CDEF.
  14. //
  15. //    NOTE: This routine assumes that the CountDITL, AppendDITL & ShortenDITL are
  16. //            available. (System 7 or CommToolbox is installed);
  17. //
  18. //   returns: void
  19. //----------------------------------------------------------------------------------
  20.  
  21. extern Boolean panelSwap(DialogPtr theDialog, short firstPANEL, 
  22.                         short fromPanel, short toPanel, short ctlToKeep)
  23. {    
  24.  
  25. #pragma unused(fromPanel)
  26.  
  27.     Handle            h;
  28.     short            toRemove=0;
  29.     Boolean            retCode=true;
  30.     
  31.     toRemove = CountDITL(theDialog) - ctlToKeep;
  32.         
  33.     h = GetResource('DITL', firstPANEL+toPanel);
  34.     if(h) {
  35.         if(toRemove)
  36.             ShortenDITL(theDialog, toRemove);
  37.         AppendDITL(theDialog, h, overlayDITL);
  38.         ReleaseResource(h);
  39.     }
  40.     else {
  41.         ShortenDITL(theDialog, toRemove);
  42.         toRemove = 0;
  43.         retCode=false;
  44.     }
  45.     return(retCode);
  46. }
  47.  
  48. //----------------------------------------------------------------------------------
  49. //    Function: panelCmdKey
  50. //     Purpose: allow a cmd-key to operate the tabPanel CDEF.
  51. //
  52. //   returns: void
  53. //----------------------------------------------------------------------------------
  54.  
  55. extern Boolean panelCmdKey(DialogPtr theDialog, short panelID, char c, short *theItem)
  56. {
  57.     short    num;
  58.     
  59.      num = daGetCtlMax(theDialog, panelID) + 0x30;
  60.      if(c >= 0x31 && c <= num) {
  61.          num = c - 0x30;
  62.          daSetCtlValue(theDialog, panelID, num);
  63.          *theItem = panelID;
  64.          return(TRUE);
  65.      }
  66.      return(FALSE);
  67. }
  68. //----------------------------------------------------------------------------------
  69. //    Function: panelCmdTab
  70. //     Purpose: allow a cmd-tab to cycle thru tabs on the tabPanel CDEF.
  71. //
  72. //   returns: void
  73. //----------------------------------------------------------------------------------
  74.  
  75. extern Boolean panelCmdTab(DialogPtr theDialog, short panelID, char c, short *theItem)
  76. {
  77.     short    max,val;
  78.     
  79.      max = daGetCtlMax(theDialog, panelID);
  80.      val = daGetCtlValue(theDialog, panelID);
  81.      if(c == _TAB) {
  82.          val++;
  83.          if(val > max)
  84.              val = 1;
  85.          daSetCtlValue(theDialog, panelID, val);
  86.          *theItem = panelID;
  87.          return(TRUE);
  88.      }
  89.      return(FALSE);
  90. }